<?php
require_once("filehandle.php");
require_once("functions.php");

$fxid = $_REQUEST['fxid'];
$type = $_REQUEST['type'];

if (empty($fxid))
	die('no file to download');

if ($type == 'xml' || $type == 'html') {
} else
	$type = 'html';

$f_handle = new filehandle();

$data = '';

$url_data = $f_handle->read_data($fxid);
if ($type == 'html') {
	$data = html_sitemap($url_data);
} else {
	$data = xml_sitemap($url_data);
}


# This line will stream the file to the user rather than spray it across the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default to
header("Content-Disposition: attachment; filename=report_$type.$type");
header("Pragma: no-cache");
header("Expires: 0");
echo $data;
?> 